﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DLTN.Entities;
using DLTN.Data;
using System.Data;

public partial class Tour_Controls_ControlTourQuocTeGroupContent : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int TotalRows = 0;
            TList<LoaiTour> TList_LoaiTour = DataRepository.LoaiTourProvider.GetPaged("TenLoaiTour like N'%" + Common.TourNuocNgoai + "%'", "ID", 0, 0, out TotalRows);
            if (TList_LoaiTour.Count > 0)
            {
                H_HiddenID.Value = TList_LoaiTour[0].Id.ToString();
                HienChauA();
                HienThiChauAu();
                HienThiChauMy();
                HienThiTourDacBiet();
            }
        }
    }

    private void HienChauA()
    {
        string strHTML = "";
        int TotalRows = 0;
        string WhereClause = "1=1";
        string WhereClause1 = "1=1";

        WhereClause1 += " and TenSubTour like N'%" + Common.TourChauA + "%' and IdLoaiTour in (select Id from LoaiTour where Id = " + H_HiddenID.Value + ")";
        TList<SubTour> TList_SubTour = DataRepository.SubTourProvider.GetPaged(WhereClause1, "ID", 0, 0, out TotalRows);
        if (TList_SubTour.Count > 0)
        {
            WhereClause += " and IdSubTour in (select Id from SubTour where Id = " + TList_SubTour[0].Id + " )";
            TList<Tour> TList_Tour = DataRepository.TourProvider.GetPaged(WhereClause, "NgayCapNhat DESC", 0, 5, out TotalRows);
            if (TList_Tour.Count > 0)
            {
                int j = 1;
                //Phần liệt kê
                
                for (int i = 0; i <= TList_Tour.Count - 1; i++)
                {
                    strHTML += "<div id=\"tin-tuc-content-" + j + "\">";
                    strHTML += "<div>";
                    strHTML += "<div style=\"float: left; margin-top: 5px;\"><div style=\"float: left; height:33px;\">";
                    strHTML += "<img src=\"images/dltn/caydua.png\"></div>";
                    strHTML += "<div style=\"float: right; margin-left: 5px;\"><div class=\"chumenunhomtour\">";
                    strHTML += "<a href='SubListTour/" + TList_Tour[i].IdSubTour + "/" + GetTieuDe(Common.TourChauA) + ".aspx' >" + Common.TourChauA.ToUpper() + "</a></div>";
                    strHTML += "<div class=\"date-time\">" + Common.StandardStringjquery(TList_Tour[i].NgayCapNhat.ToString("''dd/MM/yyyy, HH:mm 'GMT+7'")) + "</div></div></div>";
                    strHTML += "<a href=\"Tour/" + TList_Tour[i].Id + "/" + TList_Tour[i].IdSubTour + "/" + GetTieuDe(TList_Tour[i].TieuDe) + ".aspx" + "\">";
                    strHTML += "<img class='radius' alt='" + TList_Tour[i].TieuDe + "' src=\"upload/Tour/" + TList_Tour[i].AnhDaiDien + "\" border=\"0\" width=\"300\" height=\"150\"></a></div>";
                    strHTML += "<div style=\"text-align: justify; line-height:150%; height: 89px; font-family: Tahoma; margin-top: 3px\"><span style=\"font-weight: bold; color: red\">";
                    strHTML += "<a class=\"TinTucRight\" href='Tour/" + TList_Tour[i].Id + "/" + TList_Tour[i].IdSubTour + "/" + GetTieuDe(TList_Tour[i].TieuDe) + ".aspx'>" + TList_Tour[i].TieuDe + "</a></span>: ";
                    strHTML += "</span><br>" + formatString(TList_Tour[i].TomTat.ToString(), 260) + "</div>";
                    strHTML += "<div style=\"margin-top: -5px; padding-left: 207px\"><div class=\"seemoreDiv\">";
                    strHTML += "<a href=\"Tour/" + TList_Tour[i].Id + "/" + TList_Tour[i].IdSubTour + "/" + GetTieuDe(TList_Tour[i].TieuDe) + ".aspx" + "\" class=\"seemoreText\"><div style=\"padding-top: 2px; padding-left: 2px\">Xem tiếp</div></a>";
                    strHTML += "</div></div></div>";
                    
                    j++;
                }
            }
            else
            {
                strHTML += "<div style=\"float: left; margin-top: 5px;\"><div style=\"float: left\">";
                strHTML += "<img src=\"images/dltn/caydua.png\"></div>";
                strHTML += "<div style=\"float: right; margin-left: 5px;\"><div class=\"chumenunhomtour\">" + Common.TourChauA.ToUpper() + "</div>";
                strHTML += "<div class=\"date-time\"></div></div></div>";
            }
            lithotTour.Text = strHTML;

        }
    }

    /// <summary>
    /// Sự kiện
    /// </summary>
    /// <param name="Char"></param>
    /// <returns></returns>
    private void HienThiChauAu()
    {
        string strHTML = "";
        int TotalRows = 0;
        string WhereClause = "1=1";
        string WhereClause1 = "1=1";

        WhereClause1 += " and TenSubTour like N'%" + Common.TourChauAu + "%' and IdLoaiTour in (select Id from LoaiTour where Id = " + H_HiddenID.Value + ")";
        TList<SubTour> TList_SubTour = DataRepository.SubTourProvider.GetPaged(WhereClause1, "ID", 0, 0, out TotalRows);
        if (TList_SubTour.Count > 0)
        {
            WhereClause += " and IdSubTour in (select Id from SubTour where Id = " + TList_SubTour[0].Id + " )";
            TList<Tour> TList_Tour = DataRepository.TourProvider.GetPaged(WhereClause, "NgayCapNhat DESC", 0, 5, out TotalRows);
            if (TList_Tour.Count > 0)
            {
                int j = 1;
                //Phần liệt kê
                
                for (int i = 0; i <= TList_Tour.Count - 1; i++)
                {
                    strHTML += "<div id=\"su-kien-content-" + j + "\">";
                    strHTML += "<div>";
                    strHTML += "<div style=\"float: left; margin-top: 5px;\"><div style=\"float: left; height:33px;\">";
                    strHTML += "<img src=\"images/dltn/caydu.png\"></div>";
                    strHTML += "<div style=\"float: right; margin-left: 5px;\"><div class=\"chumenunhomtour\">";
                    strHTML += "<a href='SubListTour/" + TList_Tour[i].IdSubTour + "/" + GetTieuDe(Common.TourChauAu) + ".aspx' >" + Common.TourChauAu.ToUpper() + "</a></div>";
                    strHTML += "<div class=\"date-time\">" + Common.StandardStringjquery(TList_Tour[i].NgayCapNhat.ToString("''dd/MM/yyyy, HH:mm 'GMT+7'")) + "</div></div></div>";
                    strHTML += "<a href=\"Tour/" + TList_Tour[i].Id + "/" + TList_Tour[i].IdSubTour + "/" + GetTieuDe(TList_Tour[i].TieuDe) + ".aspx" + "\">";
                    strHTML += "<img class='radius' alt='" + TList_Tour[i].TieuDe + "' src=\"upload/Tour/" + TList_Tour[i].AnhDaiDien + "\" border=\"0\" width=\"300\" height=\"150\"></a></div>";
                    strHTML += "<div style=\"text-align: justify; line-height:150%; height: 89px; font-family: Tahoma; margin-top: 3px\"><span style=\"font-weight: bold; color: red\">";
                    strHTML += "<a class=\"TinTucRight\" href='Tour/" + TList_Tour[i].Id + "/" + TList_Tour[i].IdSubTour + "/" + GetTieuDe(TList_Tour[i].TieuDe) + ".aspx'>" + TList_Tour[i].TieuDe + "</a></span>: ";
                    strHTML += "</span><br>" + formatString(TList_Tour[i].TomTat.ToString(), 260) + "</div>";
                    strHTML += "<div style=\"margin-top: -5px; padding-left: 207px\"><div class=\"seemoreDiv\">";
                    strHTML += "<a href=\"Tour/" + TList_Tour[i].Id + "/" + TList_Tour[i].IdSubTour + "/" + GetTieuDe(TList_Tour[i].TieuDe) + ".aspx" + "\" class=\"seemoreText\"><div style=\"padding-top: 2px; padding-left: 2px\">Xem tiếp</div></a>";
                    strHTML += "</div></div></div>";
                    
                    j++;
                }
            }
            else
            {
                strHTML += "<div style=\"float: left; margin-top: 5px;\"><div style=\"float: left\">";
                strHTML += "<img src=\"images/dltn/caydu.png\"></div>";
                strHTML += "<div style=\"float: right; margin-left: 5px;\"><div class=\"chumenunhomtour\">" + Common.TourChauAu.ToUpper() + "</div>";
                strHTML += "<div class=\"date-time\"></div></div></div>";
            }
            litTrongNuocTour.Text = strHTML;
        }

    }

    /// <summary>
    /// Thong cao bao chi
    /// </summary>
    /// <param name="Char"></param>
    /// <returns></returns>
    private void HienThiChauMy()
    {
        string strHTML = "";
        int TotalRows = 0;
        string WhereClause = "1=1";
        string WhereClause1 = "1=1";
        WhereClause1 += " and TenSubTour like N'%" + Common.TourChauMy + "%' and IdLoaiTour in (select Id from LoaiTour where Id = " + H_HiddenID.Value + ")";
        TList<SubTour> TList_SubTour = DataRepository.SubTourProvider.GetPaged(WhereClause1, "ID", 0, 0, out TotalRows);
        if (TList_SubTour.Count > 0)
        {
            WhereClause += " and IdSubTour in (select Id from SubTour where Id = " + TList_SubTour[0].Id + " )";
            TList<Tour> TList_Tour = DataRepository.TourProvider.GetPaged(WhereClause, "NgayCapNhat DESC", 0, 5, out TotalRows);
            if (TList_Tour.Count > 0)
            {
                int j = 1;
                //Phần liệt kê
                
                for (int i = 0; i <= TList_Tour.Count - 1; i++)
                {
                    strHTML += "<div id=\"thong-cao-bao-chi-content-" + j + "\">";
                    strHTML += "<div>";
                    strHTML += "<div style=\"float: left; margin-top: 5px;\"><div style=\"float: left; height:33px;\">";
                    strHTML += "<img src=\"images/dltn/specialTour.png\"></div>";
                    strHTML += "<div style=\"float: right; margin-left: 5px;\"><div class=\"chumenunhomtour\">";
                    strHTML += "<a href='SubListTour/" + TList_Tour[i].IdSubTour + "/" + GetTieuDe(Common.TourChauMy) + ".aspx' >" + Common.TourChauMy.ToUpper() + "</a></div>";
                    strHTML += "<div class=\"date-time\">" + Common.StandardStringjquery(TList_Tour[i].NgayCapNhat.ToString("''dd/MM/yyyy, HH:mm 'GMT+7'")) + "</div></div></div>";
                    strHTML += "<a href=\"Tour/" + TList_Tour[i].Id + "/" + TList_Tour[i].IdSubTour + "/" + GetTieuDe(TList_Tour[i].TieuDe) + ".aspx" + "\">";
                    strHTML += "<img class='radius' alt='" + TList_Tour[i].TieuDe + "' src=\"upload/Tour/" + TList_Tour[i].AnhDaiDien + "\" border=\"0\" width=\"300px\" height=\"150px\"></a></div>";
                    strHTML += "<div style=\"text-align: justify; line-height:150%; height: 89px; font-family: Tahoma; margin-top: 3px\"><span style=\"font-weight: bold; color: red\">";
                    strHTML += "<a class=\"TinTucRight\" href='Tour/" + TList_Tour[i].Id + "/" + TList_Tour[i].IdSubTour + "/" + GetTieuDe(TList_Tour[i].TieuDe) + ".aspx'>" + TList_Tour[i].TieuDe + "</a></span>: ";
                    strHTML += "</span><br>" + formatString(TList_Tour[i].TomTat.ToString(), 260) + "</div>";
                    strHTML += "<div style=\"margin-top: -5px; padding-left: 207px\"><div class=\"seemoreDiv\">";
                    strHTML += "<a href=\"Tour/" + TList_Tour[i].Id + "/" + TList_Tour[i].IdSubTour + "/" + GetTieuDe(TList_Tour[i].TieuDe) + ".aspx" + "\" class=\"seemoreText\"><div style=\"padding-top: 2px; padding-left: 2px\">Xem tiếp</div></a>";
                    strHTML += "</div></div></div>";
                    
                    j++;
                }
            }
            else
            {
                strHTML += "<div style=\"float: left; margin-top: 5px;\"><div style=\"float: left\">";
                strHTML += "<img src=\"images/dltn/specialTour.png\"></div>";
                strHTML += "<div style=\"float: right; margin-left: 5px;\"><div class=\"chumenunhomtour\">" + Common.TourChauMy.ToUpper() + "</div>";
                strHTML += "<div class=\"date-time\"></div></div></div>";
            }
            litDocTour.Text = strHTML;
        }
    }

    /// <summary>
    /// Dang ky nhan New letter
    /// </summary>
    /// <param name="Char"></param>
    /// <returns></returns>
    private void HienThiTourDacBiet()
    {
        string strHTML = "";
        int TotalRows = 0;
        string WhereClause = "1=1";
        string WhereClause1 = "1=1";
        WhereClause1 += " and TenSubTour like N'%" + Common.TourDacBiet + "%' and IdLoaiTour in (select Id from LoaiTour where Id = " + H_HiddenID.Value + ")";
        TList<SubTour> TList_SubTour = DataRepository.SubTourProvider.GetPaged(WhereClause1, "ID", 0, 0, out TotalRows);
        if (TList_SubTour.Count > 0)
        {
            WhereClause += " and IdSubTour in (select Id from SubTour where Id = " + TList_SubTour[0].Id + " )";
            TList<Tour> TList_Tour = DataRepository.TourProvider.GetPaged(WhereClause, "NgayCapNhat DESC", 0, 5, out TotalRows);
            if (TList_Tour.Count > 0)
            {
                int j = 1;
                //Phần liệt kê
                
                for (int i = 0; i <= TList_Tour.Count - 1; i++)
                {
                    strHTML += "<div id=\"dang-ky-nhan-new-letter-content-" + j + "\">";
                    strHTML += "<div>";
                    strHTML += "<div style=\"float: left; margin-top: 5px;\"><div style=\"float: left; height:33px;\">";
                    strHTML += "<img src=\"images/dltn/internationTour.png\"></div>";
                    strHTML += "<div style=\"float: right; margin-left: 5px;\"><div class=\"chumenunhomtour\">";
                    strHTML += "<a href='SubListTour/" + TList_Tour[i].IdSubTour + "/" + GetTieuDe(Common.TourDacBiet) + ".aspx' >" + Common.TourDacBiet.ToUpper() + "</a></div>";
                    strHTML += "<div class=\"date-time\">" + Common.StandardStringjquery(TList_Tour[i].NgayCapNhat.ToString("''dd/MM/yyyy, HH:mm 'GMT+7'")) + "</div></div></div>";
                    strHTML += "<a href=\"Tour/" + TList_Tour[i].Id + "/" + TList_Tour[i].IdSubTour + "/" + GetTieuDe(TList_Tour[i].TieuDe) + ".aspx" + "\">";
                    strHTML += "<img class='radius' alt='" + TList_Tour[i].TieuDe + "' src=\"upload/Tour/" + TList_Tour[i].AnhDaiDien + "\" border=\"0\" width=\"300\" height=\"150\"></a></div>";
                    strHTML += "<div style=\"text-align: justify; line-height:150%; height: 89px; font-family: Tahoma; margin-top: 3px\"><span style=\"font-weight: bold; color: red\">";
                    strHTML += "<a class=\"TinTucRight\" href='Tour/" + TList_Tour[i].Id + "/" + TList_Tour[i].IdSubTour + "/" + GetTieuDe(TList_Tour[i].TieuDe) + ".aspx'>" + TList_Tour[i].TieuDe + "</a></span>: ";
                    strHTML += "</span><br>" + formatString(TList_Tour[i].TomTat.ToString(), 260) + "</div>";
                    strHTML += "<div style=\"margin-top: -5px; padding-left: 207px\"><div class=\"seemoreDiv\">";
                    strHTML += "<a href=\"Tour/" + TList_Tour[i].Id + "/" + TList_Tour[i].IdSubTour + "/" + GetTieuDe(TList_Tour[i].TieuDe) + ".aspx" + "\" class=\"seemoreText\"><div style=\"padding-top: 2px; padding-left: 2px\">Xem tiếp</div></a>";
                    strHTML += "</div></div></div>";
                    
                    j++;
                }
            }
            else
            {
                strHTML += "<div style=\"float: left; margin-top: 5px;\"><div style=\"float: left\">";
                strHTML += "<img src=\"images/dltn/internationTour.png\"></div>";
                strHTML += "<div style=\"float: right; margin-left: 5px;\"><div class=\"chumenunhomtour\">" + Common.TourDacBiet.ToUpper() + "</div>";
                strHTML += "<div class=\"date-time\"></div></div></div>";
            }
            litTourNuocNgoai.Text = strHTML;
        }
    }


    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }

    public string formatString(string str, int n)
    {
        string kq = "";

        if (str.Length > n)
            kq = str.Substring(0, n + 1) + "...";
        else
            kq = str;

        return kq;
    }
}